﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type RichTextBox}">
        <Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
        <Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBoxForegroundThemeBrush}" />
        <Setter Property="Background" Value="{DynamicResource TextBoxBackgroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderThemeBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RichTextBox}">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="BackgroundElement"  Background="{TemplateBinding Background}" Margin="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" />
                        <Border x:Name="BorderElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" />
                        <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{DynamicResource TextBoxDisabledBackgroundThemeBrush}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource TextBoxDisabledBorderThemeBrush}" />
                            <Setter Property="Foreground" Value="{DynamicResource TextBoxDisabledForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="False">
                            <Setter TargetName="BackgroundElement" Property="Opacity" Value="{DynamicResource TextControlBackgroundThemeOpacity}" />
                            <Setter TargetName="BorderElement" Property="Opacity" Value="{DynamicResource TextControlBorderThemeOpacity}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BackgroundElement" Property="Opacity" Value="{DynamicResource TextControlPointerOverBackgroundThemeOpacity}" />
                            <Setter TargetName="BorderElement" Property="Opacity" Value="{DynamicResource TextControlPointerOverBorderThemeOpacity}" />
                        </MultiTrigger>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter  Property="BorderBrush" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>